package com.mdc.mansion.dataaccess.common.context;

import com.mdc.mansion.common.util.ThreadMap;
import com.mdc.mansion.dataaccess.modules.restaurant.entity.Restaurant;
import com.mdc.mansion.dataaccess.modules.restaurant.entity.RestaurantStaff;

/**<p>com.mdc.mansion.dataaccess.common.context.ContextHolder</p>
 * <p>Title: ContextHolder</p>
 * <p>Copyright: Copyright © 2010-2014</p>
 * @version 1.0
 */
public class ContextHolder {

    public static final String CURRENT_LOGIN_ACCOUNT = "current_login_account";
    
    public static final String CURRENT_USER_NAME = "current_user_name";
    
    public static final String CURRENT_RESTAURANT_ID = "current_restaurant_id";
    
    public static final String CURRENT_ROLE_TYPE = "current_role_type";
    
    public static final String CURRENT_MERCHENT_ID = "current_merchent_id";

    public static final String CURRENT_RESTAURANT = "CURRENT_RESTAURANT";

    public static final String CURRENT_P = "CURRENT_P";

    public static final String CURRENT_RESTAURANT_STAFF = "CURRENT_RESTAURANT_STAFF";

    public static void registerLoginAccount(String value){
        ThreadMap.put(CURRENT_LOGIN_ACCOUNT, value);
    }
    public static void registerP(String value){
        ThreadMap.put(CURRENT_P, value);
    }

    public static void registerUserName(String value){
        ThreadMap.put(CURRENT_USER_NAME, value);
    }
    public static void registerRestaurantId(String value){
        ThreadMap.put(CURRENT_RESTAURANT_ID, value);
    }
    public static void registerRoelType(String value){
        ThreadMap.put(CURRENT_ROLE_TYPE, value);
    }
    
    public static void registerRestaurant(Restaurant value){ThreadMap.put(CURRENT_RESTAURANT, value);}
    public static void registerRestaurantStaff(RestaurantStaff value){ThreadMap.put(CURRENT_RESTAURANT_STAFF, value);}

    public static String currentLoginAccount(){
        return (String)ThreadMap.get(CURRENT_LOGIN_ACCOUNT);
    }
    public static String currentP(){
        return (String)ThreadMap.get(CURRENT_P);
    }

    public static String currentUserName(){
        return (String)ThreadMap.get(CURRENT_USER_NAME);
    }
    public static String currentRestaurantId(){
        return (String)ThreadMap.get(CURRENT_RESTAURANT_ID);
    }
    
    public static String currentRoleType(){
        return (String)ThreadMap.get(CURRENT_ROLE_TYPE);
    }
    public static Restaurant currentRestaurant(){return (Restaurant) ThreadMap.get(CURRENT_RESTAURANT);}
    public static RestaurantStaff currentRestaurantStaff(){return (RestaurantStaff) ThreadMap.get(CURRENT_RESTAURANT_STAFF);}

    public static void destroy(){
        ThreadMap.clear();
    }
}
